from pyecharts.charts import Map
from pyecharts.options import VisualMapOpts, LabelOpts

map1 = Map()
# data = [("北京", 99), ("上海", 199), ("湖南", 299), ("台湾", 399), ("广州", 499)]
data = [("北京市", 99), ("上海市", 199), ("湖南省", 299), ("台湾省", 399), ("广东省", 499)]
# 添加数据
map1.add("测试地图", data, "china", label_opts=LabelOpts(is_show=False))
map1.set_global_opts(
    visualmap_opts=VisualMapOpts(
        is_show=True,
        is_piecewise=True,
        pieces=[
            {"min": 1, "max": 9, "label": "1-9人", "color": "#CCFFFF"},
            {"min": 10, "max": 99, "label": "10-99人", "color": "#FFFF99"},
            {"min": 100, "max": 199, "label": "100-499人", "color": "#FF9966"},
            {"min": 200, "max": 299, "label": "500-999人", "color": "#FF6666"},
            {"min": 300, "max": 399, "label": "1000-9999人", "color": "#CC3333"},
            {"min": 400, "label": "400以上", "color": "#990033"}
        ]
    )
)
# 绘图
map1.render("简单疫情图.html", encodings="UTF-8")
# map1.render_notebook()
